<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//根路由
Route::get('/', function () {
    return view('welcome');
});

//例如访问/home地址则路由可以写成如下
Route::get('/home',function(){
    echo '当前访问的地址是/home';
});

//any语法
Route::any('/test1',function(){
    echo '当前访问的地址是/test1';
});

//match 语法
Route::match(['get'],'/test2',function(){
    echo '当前访问的地址是/test2';
});

//路由传参数,必选参数
Route::any('/test3/{id}',function($id){    // $id=0 即使这样也会报错
    echo "当前用户的id是" .$id;
});

//可选参数
Route::any('/test4/{id?}',function($id = 0){
    echo "当前用户id是" .$id;
});

//通过? 形式传递get参数
Route::any('/test5',function(){
    echo "当前的用户id是" . $_GET['id'];
});

//路由别名
// Route::any('/test5/addsds/dsdsds/adsds',function(){
//     echo "当前用户id是" . $_GET['id'];
// })->name('zhangsan');

//路由群组
Route::group(['prefix'=>'admin'],function(){
    Route::get('test1',function(){
        echo '匹配 /admin/test1 ';
    });
    Route::get('test2',function(){
        echo '匹配 /admin/test2';
    });
    Route::get('test3',function(){
        echo '匹配 /admin/test3';
    });
});
//控制器路由写法
Route::get('/home/test/test1','TestController@test1');

//分目录下的前后后路由
Route::get('/home/index/index','Home\IndexController@index');
Route::get('/admin/index/index','Admin\IndexController@index');

//测试用户输入
Route::get('/home/test/test2','TestController@test2');


//DB门面的增删改查
Route::group(['prefix'=>'home/test'],function(){
    Route::get('add','TestController@add');
    Route::get('del','TestController@del');
    Route::get('update','TestController@update');
    Route::get('select','TestController@select');

    //模板变量赋值等问题
    Route::get('test3','TestController@test3');
    Route::get('test4','TestController@test4');
    //模板继承
    Route::get('test5','TestController@test5');

});

//csrf验证
Route::get('/home/test/test6','TestController@test6');
Route::post('/home/test/test7','TestController@test7')->name('test7');

//模型的增删改查
Route::any('/home/test/test8','TestController@test8');
Route::get('/home/test/test9','TestController@test9');
Route::get('/home/test/test10','TestController@test10');
Route::get('/home/test/test11','TestController@test11');
Route::get('/home/test/test12','TestController@test12');

//自动验证(二合一方法,自己提交给自己)
Route::any('/home/test/test13','TestController@test13');

//文件上传
Route::any('/home/test/test14','TestController@test14');

//数据分页
Route::get('/home/test/test15','TestController@test15');


//ajax响应
Route::get('/home/test/test16','TestController@test16');
Route::get('/home/test/test17','TestController@test17');

//会话控制
Route::get('/home/test/test18','TestController@test18');

//缓存操作
Route::get('/home/test/test19','TestController@test19');

//联表查询
Route::get('/home/test/test20','TestController@test20');

//关联模型
//一对一
Route::get('/home/test/test21','TestController@test21');
//一对多
Route::get('/home/test/test22','TestController@test22');
//多对多
Route::get('/home/test/test23','TestController@test23');
